package com.atguigu.java3;

import org.junit.Test;

import java.io.File;

/**
 * @Description
 * @Author codingBee
 * @Date 2020/6/22/22:39
 * <p>
 * <p>
 * <p>
 * File 类的使用
 * 1.File 类是一个对象，代表一个文件或一个文件目录(俗称：文件夹)
 * 2.File 类声明在 java.io 包下
 */
public class FileTest {
    /***
     * 1.如何创建 File 类的实例
     *      File file = new File(String filePath);
     *      File file = new File(String parentPath,String childPath);
     *      File file = new File(File parentFile,String childPath);
     * 2.文件路径：相对路径、绝度路径
     * 3.路径分隔符：windows：\\   unix：/ 如果想通用的话就使用 {@link java.io.File#separator}
     */
    @Test
    public void test1() {
        //构造器1
        File file = new File("he.txt");//相当于当前 module
        //File file1 = new File("E:\\Develop\\Study\\WorkSpace\\Idea\\javaSenior\\day08\\hello.txt");
        // 通用型写法
        File file1 = new File("E:" + File.separator + "Develop" + File.separator + "Study" + File.separator + "WorkSpace:" + File.separator + "Idea" + File.separator + "javaSenior" + File.separator + "day08" + File.separator + "hello.txt");
        System.out.println(file);
        System.out.println(file1);
        //构造器2
        File file2 = new File("D:\\workspace_idea1","JavaSenior");
        System.out.println(file2);
        //构造器3
        File  file3 = new File (file2, "hi.txt");
        System.out.println(file3);
    }
}
